package com.trytry.entity;

import java.util.List;

public class Page<T> {
	
	private int pageSize;
    private int totalPage; 
    private int rowCount;
    private int currentPage;
    private boolean hasNextPage;
    private boolean hasPreviousPage;
    private List<T> list;
    
	public Page() {
		super();
	}
	public Page(int pageSize, int rowCount, int currentPage) {
		super();
		this.pageSize = pageSize;
		this.rowCount = rowCount;
		this.currentPage = currentPage;
		this.totalPage=total();
		this.hasNextPage=hasnext(this.totalPage);
		this.hasPreviousPage=haspre(this.currentPage);
	}
	private int total(){
		int total=this.rowCount%this.pageSize==0?this.rowCount/this.pageSize:this.rowCount/this.pageSize+1;
		return total ;
	}
	private boolean hasnext(int total){
    	if(this.currentPage==total){
    		return false;
    	}else{
    	return true;
    	}
    	}
    private boolean haspre(int current){
    	if(this.currentPage==current){
    		return false;
    	}else{
    	return true;
    	}
    	}
    
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getRowCount() {
		return rowCount;
	}
	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public boolean isHasNextPage() {
		return hasNextPage;
	}
	public void setHasNextPage(boolean hasNextPage) {
		this.hasNextPage = hasNextPage;
	}
	public boolean isHasPreviousPage() {
		return hasPreviousPage;
	}
	public void setHasPreviousPage(boolean hasPreviousPage) {
		this.hasPreviousPage = hasPreviousPage;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
    
}
